/*
	Name: So Hoan Hao
	Copyright: 
	Author: Quang
	Date: 09/03/14 17:34
	Description: Liet ke cac so hoan hao < 1000
*/

#include <conio.h>
#include <stdio.h>

// ===== Ham kiem tra 1 so co phai la hoan hao khong?
int isHoanHao(int n){
	int sum = 0;
	for(int i = 1 ; i < n ; i++){
		if(n %  i== 0 ) sum = sum + i;
	}
	if (sum == n) return 1;
	else return 0;
}
// ====== Chuong trinh chinh
/*
	Lap tu 1 cho toi 1000
	neu no la so hoan hao thi in ra man hinh
*/
int main(){
	printf("Cac so hoan hao trong pham vi 1000: \n");
	for(int i = 1; i< 1000;i ++){
		if( isHoanHao(i)) printf("%d \n",i);
	}
	getch();
}
